import Vue from 'vue'


let page = {
  total: 1,
  startIndex: 0,
  stepNumber: 40,
  currentPage: 1
};


let data={
  configArgList:[],
  configArgTypes :[
    {value:100,name:"公共"},
    {value:200,name:"PC商城"},
    {value:300,name:"后台系统"},
    {value:400,name:"APP"}
  ],
  configArgStatus :[
    {value:100,name:"已启用"},
    {value:-1,name:"未启用"},
  ]
}
let status={
  actionModal:{
    isShow:false,
    title:'',
  },
  modifyModal:{
    isShow:false,
    isLoading:true,
    title:'',
    content:'',
  },
  detailModal:{
    isShow:false,
    detail:{}
  },
  configArgRules:{
    zhName: [
      {required: true, message: '中文名称不能为空', trigger: 'blur'}
    ],
    enName: [
      {required: true, message: '英文名称不能为空', trigger: 'blur'}
    ],
    value:[
      {required: true, message: '参数值不能为空', trigger: 'blur'}
    ],
    type:[
      {required: true,  type: "number",message: '请选择类型', trigger: 'change',min:1},

    ],

  }
};
let params={
  searchParams:{
    type:-1
  },
  configArg:{
    id:"",
    zhName:"",
    enName:"",
    value:"",
    status:0,
    type:0,
    description:"",
  },
  deleteConfigArgId:""
};
let  tableTitles=function (self) {
  var titles =  [

    {
      width: 70,
      type: 'index',
      align: 'center'
    },
    {
      title: '英文名称',
      key: 'enName',
      width: 150,
      align: 'center',
      render: (h, params) => {
        return h('a',{
          on: {
            click: () => {
              self.showDetail(params.index)
            }
          }
        },params.row.enName);
      },
    },
    {
      title: '中文名称',
      key: 'zhName',
      width: 150,
      align: 'center'
    },
    {
      title: '参数值',
      key: 'value',
      width: 350,
      align: 'center',
      render: (h, params) => {
        return h('div',params.row.value.length > 44 ? params.row.value.substring(0,43) + "..." : params.row.value);
      },
    },
    {
      title: '状态',
      key: 'status',
      width:80,
      align: 'center',
      render: (h, params) => {
        return h('div',params.row.status == 100 ? "已启用" : "未启用");
      },
    },
    {
      title: '类型',
      key: 'type',
      width: 120,
      align: 'center',
      render: (h, params) => {
        let configArgType = self.configArgTypes.filter(type => type.value === params.row.type);
        return h('div',null != configArgType ? configArgType[0].name : "");
      },
    },
    {
      title: '说明',
      key: 'description',
      align: 'center',
      minWidth:200,
      render: (h, params) => {
        return h('div',params.row.description.length > 35 ? params.row.description.substring(0,34) + "..." : params.row.description);
      },
    },
    {
      title: '操作',
      key: 'action',
      align: 'center',
      width:100,
      fixed: 'right',
      render: (h, params) => {
        return h('div', [

          self.$authority('OTHER-2-201')? h('Button', {
            props: {type: 'primary', size: 'small', icon: "ios-create",},
            style: {marginRight: '10px', marginTop: '6px', marginBottom: '6px'},
            on: {
              click: () => {
                self.modify(params.index)
              }
            }
          }, "编辑"):h('span',''),
          self.$authority('OTHER-2-202')?h('Button', {
            props: {type: 'error', size: 'small', icon: "md-trash",},
            style: {marginRight: '10px', marginTop: '6px', marginBottom: '6px'},
            on: {
              click: () => {
                self.deleteAction(params.row.id)
              }
            }
          }, "删除 "):h('span',''),
        ])
      },
    }
  ]
  return self.$authTableTitles(titles) ;
};



export  default  {
  tPage: page,
  tStatus: status,
  tParam: params,
  tData: data,
  listTableTitles:tableTitles,
};
